<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../css/reset.css">
    <style>
        .wrap {
            margin: 10px;
        }

        .list {
            margin-top: 10px;
            line-height: 40px;
            text-indent: 10px;
        }

        .list li {
            border: 1px dashed #333;
        }

        .list li+li {
            border-top: 0;
        }
    </style>
</head>

<body>
    <div class="wrap">
        <button>节点克隆</button>
        <ul class="list">
            <li class="first">01</li>
            <li>02</li>
            <li class="mid">03</li>
            <li>04</li>
            <li>05</li>
            <li class="last">06</li>
        </ul>
    </div>
</body>
<script>


    // 点击 替换元素 按钮 => 创建一个li替换mid

    var btn = document.getElementsByTagName("button")[0];
    var ul = document.getElementsByClassName("list")[0];
    var wrap = document.getElementsByClassName("wrap")[0];



    // 替换节点 => 父元素统筹

    // Element.cloneNode(bool)   => 返回被克隆的新节点

    // bool  是否深度克隆
    // false (默认)  只克隆元素本身及其相关属性,不克隆子内容
    // true          既克隆元素本身及其相关属性,又克隆子内容



    // 克隆list 放到wrap的最后面
    btn.onclick = function () {
        var cloneEle = ul.cloneNode(true);
        wrap.appendChild(cloneEle);
    }











</script>

</html>